package com.rp.system.dao;

import org.raptor.orm.hibernate.DbaHibernateTemplateSupport;
import org.springframework.stereotype.Repository;

import com.rp.common.utils.RpUtil;
import com.rp.system.po.Button;

@Repository
public class ButtonDao extends DbaHibernateTemplateSupport<Button> {

	
	public void addDefaultButton(String moduleAlias) throws Exception{
		if(!RpUtil.isNullOrEmpty(moduleAlias)){
			Button addBtn = new Button();
			addBtn.setId(RpUtil.createGuid());
			addBtn.setType("add");
			addBtn.setText("新增");
			addBtn.setCreateDate(RpUtil.getCurrentDatetime());
			addBtn.setModuleAlias(moduleAlias);
			this.save(addBtn);
			
			Button saveBtn = new Button();
			saveBtn.setId(RpUtil.createGuid());
			saveBtn.setType("save");
			saveBtn.setText("保存");
			saveBtn.setCreateDate(RpUtil.getCurrentDatetime());
			saveBtn.setModuleAlias(moduleAlias);
			this.save(saveBtn);
			
			Button deleteBtn = new Button();
			deleteBtn.setId(RpUtil.createGuid());
			deleteBtn.setType("delete");
			deleteBtn.setText("删除");
			deleteBtn.setCreateDate(RpUtil.getCurrentDatetime());
			deleteBtn.setModuleAlias(moduleAlias);
			this.save(deleteBtn);
		}else{
			throw new Exception("模块别名为null或空字符");
		}
	}
	
}
